The present invention relates to image processing.
An electronic image, such as a digital image, can be represented by an array of closely packed pixels that are basic picture elements. Each pixel represents a local portion of the image and alone or together with other pixels determines local attributes for the image portion. For example, the local attributes include graphical attributes, such as color, gray level, luminosity or transparency.
The local attributes of a pixel can also include a depth value corresponding to a distance between the object represented by the pixel and a reference point defined by a focal distance at which an object is in focus when it is imaged by a conventional or a digital camera. The optics of the camera maps objects at the focal distance to a focal plane defined by the film of the conventional camera or the sensor array of the digital camera. Objects that are closer or farther away than the focal distance are mapped in front of or behind the focal plane and may appear blurred in the photograph. For a digital image, the depth values of the pixels can be arbitrarily defined or altered by a user or a computer application.
Electronic images can be generated or processed by graphical software applications, such as presentation, animation, painting and design applications, or electronic devices such as scanners and digital cameras. During image processing, different electronic filters can be used to adjust the image. In general, a filter is defined by a transformation applied to pixel values of a received image to generate an output image. Electronic filters can achieve various visual effects. Some electronic filters mimic conventional photographic filters such as lenses and apertures that blur, sharpen or otherwise transform images. Other filters transform images in unusual ways. For example, a pointillism filter transforms a digitized photograph into a pointillistic painting in which small strokes of color are applied so that from a distance the strokes blend together to represent objects in the painting.
A traditional filtering effect is depth of field filtering that changes the depth in which objects seem to be in focus even though they are closer or farther away than the focal distance. A large depth of field implies that objects seem to be in focus even at distances that are much larger or smaller than the focal distance. A small depth of field implies that only objects at or near the focal distance seem to be in focus and other objects seem blurred. To narrow a large depth of field electronically, a blur filter can be selectively applied to different portions of a digital image. No blur is applied to image portions representing objects at the focal distance, and the closer or farther away an object is than the focal distance, the more blur is applied to the image portion representing that object.
Typically, a filter uses a kernel to generate a new value for a pixel, whose location is referred to as the center of the kernel. The kernel is defined by weights assigned to pixels in a neighborhood surrounding the center of the kernel in the image. The set of pixels that have substantially non-zero weights is referred to as the kernel's support. When the filter is applied, a new value is generated for the pixel at the center such that each pixel in the kernel's support contributes to the new pixel value in proportion to the weight assigned to the pixel by the kernel.